package com.ehualu.core.util.sms.service;

import java.io.InputStream;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ehualu.core.util.SmsUtil;
import com.ehualu.core.util.sms.pojo.Sms;


/**
 * 亿美软通短信接口
 * @author Administrator
 *
 */
public class EmayService {

private static final Logger logger = LoggerFactory.getLogger(EmayService.class);
	
	/**
	 * 短信发送(亿美软通)
	 * @param phone
	 * @param msg
	 * @return
	 */
	public static String sendSms(Sms sms) {
		String result = SmsUtil.sendSms(sms.getMessage(), sms.getPhone());
		logger.info("smsEmay result:"+result);
		InputStream inputStream = SmsUtil.class.getClassLoader()
				.getResourceAsStream("smserror.properties");
		Properties smserror = new Properties();
		try {
			smserror.load(inputStream);
			String returnValue = smserror.getProperty(result);
			logger.info("smsEmay returnValue:"+returnValue);
			if(returnValue == null || !"".equals(returnValue)){
				returnValue = "发送失败";
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
}
